"use strict";

import {tempbuffer} from "../utils/glutils.js";

export default class Mirror {
	static r = 24;

	constructor(x, y, rad) {
		this.x = x;
		this.y = y;
		this.nor = [Math.sin(rad), -Math.cos(rad)];
	}

	turn() {
		
	}

	/*
     * offset must be litter than 4.
     */
	putBuffer(offset) {
		let rw = Mirror.r*this.nor[1];//Math.cos(this.rad);
		let rh = Mirror.r*this.nor[0];//Math.sin(this.rad);
		tempbuffer.set([this.x+rw,
						this.y-rh,
						this.x-rw,
						this.y+rh],
					   offset*4);
		//gl.bufferSubData(target, offset, tempbuffer);
	}

	setHandle() {
		let rw = 32*this.nor[1];//Math.cos(this.rad);
		let rh = 32*this.nor[0];//Math.sin(this.rad);
		tempbuffer[2] = this.x+rw;
		tempbuffer[3] = this.y-rh;
		tempbuffer[4] = this.x-rw;
		tempbuffer[5] = this.y+rh;
		//gl.bufferSubData(gl.ARRAY_BUFFER, offset, tempbuffer);
		//gl.drawArrays(gl.POINTS, first, 2);
	}
}
